from django.db import models

# Create your models here.

# 在位情况
class Case(models.Model):
    name = models.CharField(max_length=50)
    rank = models.IntegerField(blank=True,null=True)

    def __str__(self):
        return self.name
# 宿舍
class Dorm(models.Model):
    name = models.CharField(max_length=50)
    
    class Meta:
        ordering=['name']

    def __str__(self):
        return self.name

# 士官
class Person(models.Model):
    name = models.CharField(max_length=50,unique=True)
    case = models.ForeignKey(Case,on_delete=models.DO_NOTHING,related_name='person')
    birthday = models.DateField(blank=True,null=True)
    dorm = models.ForeignKey(Dorm,on_delete=models.DO_NOTHING,blank=True,null=True,related_name='person')

    class Meta:
        ordering=['dorm']

    def __str__(self):
        return self.name
